﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using PulseLibrary;

namespace PulsePrototype.PulseManagers
{
    public class RenderDescription
    {
        public Texture2D texture;
        public Vector3 position = Vector3.Zero;
        public Vector2 origin = Vector2.Zero;
        public Vector2 scale = new Vector2(1, 1);
        public float rotation = 0.0f;
        public float transparency = 1.0f;
        public Matrix worldTransform = Matrix.Identity;

        // Do note that there will be some jitter if using the rectangle
        // due to the fact that rectangles use int, not as smooth as a float/Vector2.
        // This boolean is used in the Draw method of RenderManager
        public bool drawWithVector = true;
        public RenderComponent ParentComponent;

        public Rectangle Destination
        {
            get
            {
                return new Rectangle(
                    (int)(position.X),
                    (int)(position.Y),
                    (int)(texture.Width * scale.X),
                    (int)(texture.Height * scale.Y));
            }
            set
            {
                scale.X = (value.Width / texture.Width);
                scale.Y = (value.Height / texture.Height);
                position = value.Location.ToVector3();
            }
        }

        public RenderDescription(RenderComponent parent)
        {
            ParentComponent = parent;
        }

        public RenderDescription(RenderComponent parent, Texture2D texture)
        {
            ParentComponent = parent;
            this.texture = texture;
            this.origin = new Vector2((float)texture.Width / 2f, (float)texture.Height / 2f);
        }
    }
}
